#ifndef TCPSQL_H
#define TCPSQL_H

#include "TDBInterface.h"

class ThreeCardSavedGame;


//*****************************************************************************************************
//
//  This class handles the database access for the Three Card Poker game.  It uses the singleton 
//  server-wide TrackSQL object to actually create odbc connections to the database, but the logic
//  of building the stored procedure requests and interpreting the returned result sets is done here.
//
//  This class is derived from CDBInterface, which exists to define the interface that the Connection 
//  class uses to communicate with these game-specific database access classes, and also holds some 
//  common logic.
//
//  There'll be an instance of this class for every player session created by this server process.
//
//  kharmon.  01-30-06.  #5862.
//
//*****************************************************************************************************
class ThreeCardPokerSQL : public TDBInterface
{
public:
    ThreeCardPokerSQL(TrackSQL *pTracker, TInfo *pInfo);

    // called everytime a new game is begun.
	virtual bool8 trackNewGame(int32 nBet, int32 nSideBet, uint8 nAntePayTable, 
                               int8 nSidePayTable, int32 compFactor, int32* Balance);

    // called when the user requests that cards be dealt, usually right after trackNewGame.
    virtual bool8 trackDeal(TGame *pGame);

    // called when the final status of a game has been determined.
    virtual bool8 trackGameDone(bool8 bRaised, int32 nPayAnte, int32 nPayRaise, int32 nPaySideBet,
					            int32 nOutcome, int32 nBalAdjust, int32 *pnBalance, TGame *pGame);

    // called to load any saved game that the current user might have laying around.
	virtual bool8 trackHasSavedGame(ThreeCardConnection *pConn, TGame ** ppGame, int32 * err);

    // called to (theoretically) save the game state to the database after the cards are dealt.
    virtual bool8 trackSaveGame(TGame *pGame) { return false; }

    // called to load the casino settings for the implementing game
    virtual bool8 trackGetOptions(uint8 *pnAntePayTable, uint8 *pnSidePayTable);


protected:		

	int32 createGame(int32 casinoId,
		PID, bool8 forMoney, SESSIONID, int32 compFactor,
		ThreeCardGameID, int32 anteBet, int32 pairPlusBet,
        uint8 anteBonusPayTable, uint8 pairPlusPayTable,
		int32* balance, int32* comp);

    // kharmon.  10-17-06.  #8226.  Deal now only saves the deckseed and player cards, 
    // gameDone saves the dealer cards.
	int32 deal(PID, ThreeCardGameID, int32 nDeckSeed, int32 numPlayer, uint8* player);

	int32 gameDone(int32 casinoId,
		PID, bool8 forMoney, ThreeCardGameID, char raised,
		int32 payAnte, int32 payRaise, int32 payPairPlus, int32 outcome,
		int32 balanceAdjust, int32* balance, int32* comp, 
        int32 numDealer, uint8* dealer, int32 numPlayer, uint8* player);

	int32 hasSavedGame(PID, bool8 forMoney,
		ThreeCardGameID, ThreeCardSavedGame*, bool8* exists);

    int32 getOptions(uint8* anteBonusPayTable, uint8* pairPlusPayTable);
};

#endif
